package cn.com.cetccst.compliancecheck.checker;

import static cn.com.cetccst.tools.device.Device.isRooted;

import android.content.Context;

import cn.com.cetccst.compliancecheck.R;
import cn.com.cetccst.tools.log.CommonLogger;

public class RootChecker extends Checker {
    private static RootChecker instance;
    private RootChecker(Context context) {
        super(CheckerType.Root);
        name = context.getString(R.string.compliance_root);
    }

    public static void init(Context context) {
        if(instance == null) {
            instance = new RootChecker(context);
        }
    }

    public static RootChecker getInstance() {
        return instance;
    }

    @Override
    public void check(Context context) {
        CommonLogger.info("Start check ROOT");
        super.check(context);
        if(!isEnable())
            return;
        if (isRooted()) {
            setResult(CheckResult.Violated);
        } else {
            setResult(CheckResult.Pass);
        }
    }

}
